package cm.app.login.service.impl;

import cm.app.login.service.LoginService;
import cm.data.single.entity.UsersExample;
import cm.data.single.entity.UsersExample.Criteria;
import cm.data.single.mapper.UsersMapper;
import cm.fw.utility.Utilities;

public class LoginServiceImpl implements LoginService {

    private UsersMapper usersMapper;

    @Override
    public int doLogin(String loginId, String password)
            throws Exception {

        // 検索条件を作成
        UsersExample ue = new UsersExample();
        Criteria criteria = ue.createCriteria();
        criteria.andLoginIdEqualTo(loginId);
        criteria.andPasswordEqualTo(Utilities.encodingByMd5(password));

        return usersMapper.countByExample(ue);
    }

    public UsersMapper getUsersMapper() {
        return usersMapper;
    }

    public void setUsersMapper(UsersMapper usersMapper) {
        this.usersMapper = usersMapper;
    }
}
